Skip to content

Conversation

@OlivierBBB
Copy link
Collaborator

@OlivierBBB OlivierBBB commented Nov 12, 2025

Note

Implements fork-aware MODEXP per Osaka (EIP‑7823), introducing London/Osaka MODEXP metadata, pricing and XBS OOB calls, updating MMU and counters to fork-specific sizes/costs, wiring fork into ZkCounter via RPC, and adjusting tests.

  • zktracer (core):
    • Make ZkCounter fork-aware; derive OpCodes/Trace from fork and use fork in MODEXP logic and line counts.
    • Split MODEXP into forked implementations: LondonModexpSubsection/OsakaModexpSubsection, with London/OsakaModexpMetadata.
    • Add forked MODEXP ops: London/OsakaBlakeModexpDataOperation, London/OsakaModexpPricingOobCall, London/OsakaModexpXbsOobCall.
    • Update exponent-log and return sizing to use fork-specific multipliers and max input sizes.
  • MMU:
    • Pass fork into Mmu/MmuInstructions; adjust ModexpData/ModexpZero micro-rows and component sizes per fork.
  • Precompile processing:
    • Route PRC_MODEXP to London/Osaka subsections; count rows via ModexpMetadata.getNumberOfRowsForModexp(); make MODEXP success depend on forked bounds and pricing.
    • Use fork-specific MODEXP rows and Blake rows via unified BlakeModexpData API.
  • RPC / Counter:
    • GenerateLineCountsV2 and ConflatedCountTracesV2: construct ZkCounter with resolved fork.
  • Tests:
    • Update unit/integration tests to reflect fork-aware MODEXP limits, pricing, gas, and helper utilities.

Written by Cursor Bugbot for commit 2fedec6. This will update automatically on new commits. Configure here.

With Lorenzo and François
the old tests were overwriting mbs in memory !
}

protected boolean allXbsesAreInBounds() {
return true;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: Missing maxNumberOfLines override in LondonModexpSubsection

The LondonModexpSubsection class doesn't override the maxNumberOfLines() method that was present in the original ModexpSubsection class. This causes it to inherit the default implementation from PrecompileSubsection which returns 0, instead of the correct value NB_ROWS_HUB_PRC_MODEXP (13). This affects line counting for MODEXP precompile operations and could lead to incorrect trace sizing calculations.

Fix in Cursor Fix in Web

}

protected boolean allXbsesAreInBounds() {
return true;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: Missing maxNumberOfLines override in LondonModexpSubsection

The LondonModexpSubsection class was refactored from ModexpSubsection but the maxNumberOfLines() method override was removed. The diff shows the old ModexpSubsection had this method returning NB_ROWS_HUB_PRC_MODEXP (value 13), but the new LondonModexpSubsection doesn't override it, causing it to inherit the default return value of 0 from PrecompileSubsection. This breaks the precompile subsection initialization in the constructor which calls new ArrayList<>(maxNumberOfLines()), potentially causing incorrect memory allocation and fragment list sizing for MODEXP operations.

Fix in Cursor Fix in Web

@OlivierBBB OlivierBBB force-pushed the EIP-7823-and-7883---Osaka-MODEXP-changes branch from 9ffa4a4 to 8ce1623 Compare November 20, 2025 10:25

public short getNumberOfRowsForModexp() {
return (short) (4 * (getMaxInputSize() / LLARGE));
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: Mismatch between row count formula and actual indices

The getNumberOfRowsForModexp() method calculates rows as 4 * (getMaxInputSize() / LLARGE), assuming all four MODEXP phases have equal-sized index arrays. However, the actual row count depends on INDEX_MAX_MODEXP_BASE, INDEX_MAX_MODEXP_EXPONENT, INDEX_MAX_MODEXP_MODULUS, and INDEX_MAX_MODEXP_RESULT constants from fork-specific Trace classes. If these constants aren't uniformly derived from getMaxInputSize() / LLARGE, this formula produces incorrect line counts, leading to miscounting in blakemodexp.updateTally() calls in ZkCounter.tracePrecompileCall().

Fix in Cursor Fix in Web


return tracerSharedConfiguration.isLimitless()
? new ZkCounter(l1L2BridgeSharedConfiguration)
? new ZkCounter(l1L2BridgeSharedConfiguration, fork)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will require a PR in the monorepo as well to change the ZkCounter interface, everywhere ZkCounter is called https://github.com/Consensys/linea-monorepo/blob/5aed83a5f904a1b19906dac4aa0d45656074dfd3/besu-plugins/linea-sequencer/sequencer/src/main/java/net/consensys/linea/rpc/methods/LineaEstimateGas.java#L437 - might also be the case for Besu-shomei plugin

Signed-off-by: F Bojarski <[email protected]>
Copy link
Collaborator

@letypequividelespoubelles letypequividelespoubelles left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@letypequividelespoubelles letypequividelespoubelles merged commit c2541bc into arith-dev Nov 20, 2025
14 checks passed
@letypequividelespoubelles letypequividelespoubelles deleted the EIP-7823-and-7883---Osaka-MODEXP-changes branch November 20, 2025 12:12
jonesho pushed a commit that referenced this pull request Nov 24, 2025
…2477)

* feat: constraints update

* constraints update

* first commit

* various ...

* stuff ...

* clean up

With Lorenzo and François

* fix: 99% up to par + @EqualsAndHash(callSuper = true)

One failing test (MODEXP limits)

* fix: ModexpTests

the old tests were overwriting mbs in memory !

* feat: fix ZkCounter event detection

* spotless

* spotless ... again ?

* feat: Osaka MODEXP pricing OOB call

* stuff

* spotless

* setting TOT in MODEXP's MMU instructions (DATA and ZERO)

* small stuff

* bug: use OsakaBlakeModexpOperation for Osaka rather than LondonBla

* feat: most tests are passing

* feat: constraints update

* merge arith-dev

* constraints update

* feat: byteMultiplier of leadLog in MODEXP made fork dependent

leadLog is essentially defined as

   log_2(exponent_leading_word) + multiplier * (ebs - 32)

with multiplier = 8 pre-Osaka, and 16 post-Osaka

* feat: ugly test fixes

* feat: fork dependent MODEXP_PRICING byte multiplier m * (ebs - 32)

* feat: fork dependent xbsNonzero for MODEXP_XBS

* ras: constraints commit update

* feat: add fork field to ZkCounter class

* spotless

* fix: use fork appropriate gasLimit in LowGasStipendPrecompileCallTests

* fix: disable parallelism (enabled by mistake)

* wip: fix of huge gas consumption in 'preCallProgramGasMap'

* added meaningful input for call to POINT_EVALUATION precompile in SixtyThreeSixtyFourthsPrecompileTests

* fix: initialize KZG

* constraints update

* ras: TracerTestBase now on OSAKA

* review comments

* update constraints

Signed-off-by: F Bojarski <[email protected]>

---------

Signed-off-by: F Bojarski <[email protected]>
Co-authored-by: Lorenzo Gentile <[email protected]>
Co-authored-by: F Bojarski <[email protected]>
Co-authored-by: François Bojarski <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants